package org.whusim.utils;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Config {
	static Properties prop=null;
	static String path="resource/config.properties";
	
	static{
		System.out.println("-------------");
		prop=new Properties();
		InputStream is;
		try {
			is = new BufferedInputStream(new FileInputStream(path));
			prop.load(is);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}		
	}
	
	private Config(){
		
	}
	
		
	public static String getProp(String key){
		return prop.getProperty(key);
	}


	/**
	 * @param string
	 * @param parent
	 */
	public static void setProp(String key, String value) {
		prop.setProperty(key, value);
		try {
			prop.store(new FileOutputStream("config.properties "), "changed ");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
	

}
